﻿Imports System.Net.Mail

Public Class Registration
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub CreateButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles createButton.Click

        If userFirstNameBox.Text = "" Or userLastNameBox.Text = "" Or userStreetBox.Text = "" Or userCityBox.Text = "" Or userStateBox.Text = "" Or userZipBox.Text = "" Or userDepartmentBox.Text = "" Or userEmailBox.Text = "" Or userPasswordBox.Text = "" Or userRetypeBox.Text = "" Then
            MsgBox("Please fill in all fields")

        ElseIf ((String.Compare(userPasswordBox.Text, userRetypeBox.Text)) = 0) Then

            Dim [to] As New MailAddress("cosc320twin@gmail.com")
            Dim [from] As New MailAddress("cosc320twin@gmail.com")
            Dim mail As New MailMessage([from], [to])

            mail.Subject = "Employee Profile Request"
            mail.Body = "Please review and generate a profile using the following characteristics:" &
        " First Name: " & userFirstNameBox.Text &
        " Last Name: " & userLastNameBox.Text &
        " Street: " & userStreetBox.Text &
        " City: " & userCityBox.Text &
        " State: " & userStateBox.Text &
        " Zip: " & userZipBox.Text &
         " Dept:" & userDepartmentBox.Text &
         " Email Address:" & userEmailBox.Text &
         " Password: " & userPasswordBox.Text

            mail.IsBodyHtml = True

            Dim smtp As SmtpClient = New SmtpClient()
            smtp.Host = "smtp.gmail.com"
            smtp.Port = 587
            smtp.Credentials = New System.Net.NetworkCredential("cosc320twin@gmail.com", "shumbashumba")
            smtp.EnableSsl = True
            smtp.Send(mail)
            MsgBox("Your request to create a profile has been sent to the. Upon approval and creation, you will recieve an email confirmation. Redirect to Login.")
        End If
           

    End Sub

    Protected Sub ClearButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles clearButton.Click
        userFirstNameBox.Text = ""
        userLastNameBox.Text = ""
        userStreetBox.Text = ""
        userCityBox.Text = ""
        userStateBox.Text = ""
        userZipBox.Text = ""
        userDepartmentBox.Text = ""
        userEmailBox.Text = ""
        userPasswordBox.Text = ""
        userRetypeBox.Text = ""

    End Sub

    Protected Sub BackButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles backButton.Click
        Response.Redirect("Login.aspx")
    End Sub
End Class